import Vue from 'vue';
import Vuex from 'vuex';

// 模块
import home from './modules/home';
import user from './modules/user';
Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		searchInfo: {
			text: '',
			type: ''
		},
		locationInfo: {
			lat: '',
			lng: ''
		}
	},
	mutations: {
		setSearchInfo(state, value) {
			state.searchInfo = {...value};
		},
		clearSearchInfo(state) {
			state.searchInfo = {}
		},
		setLocationInfo(state, value) {
			state.locationInfo = {
				lat: value.lat || '',
				lng: value.lng || ''
			}
		}
	},
	modules: {
		home,
		user
	},
});

export default store;
